package Slots;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Ziad Aloulou
 */
public class Console extends JPanel {

    //constantes
    public int CLAVIER_LENGTH = 4;
    //images
    public Image IMAGE_SLOTS = Toolkit.getDefaultToolkit().createImage("Images/Slots.JPG");
    //attributs
    private Main.Frame frame;
    //jcomponents
    public JPanel pnlClavier = new JPanel(new GridLayout(1, CLAVIER_LENGTH));
    public JButton btnRetour = new JButton("Retour");
    public JButton btnPlay = new JButton("Play");
    public JButton btnStop = new JButton("Stop");
    //evenements
    public Evenements evenements;
    public Display display = new Display(this);

    /**
     *
     * @param frame la fenêtre dans laquelle se trouve la console
     */
    public Console(Main.Frame frame) {
        this.frame = frame;
        evenements = new Evenements(frame, this);
        this.setOpaque(true);
        this.setLayout(new BorderLayout());
        frame.setSize(581, 620);

        this.add(pnlClavier, BorderLayout.SOUTH);
        this.add(new Display(this));
        initHotkey();//initiation des "hotkeys" du panneau
        btnInit();//initiation des buttons du panneau
        
    }

    /**
     * Initiation des buttons du panneau
     */
    public void btnInit() {
        pnlClavier.add(btnRetour);
        pnlClavier.add(btnPlay);
        pnlClavier.add(btnStop);
        btnStop.setEnabled(false);
        btnRetour.addActionListener(evenements);
        btnPlay.addActionListener(evenements);
        btnStop.addActionListener(evenements);
    }

    /**
     * Initiation des "hotkeys" du panneau
     */
    public void initHotkey() {
        btnPlay.setMnemonic(KeyEvent.VK_P);
        btnStop.setMnemonic(KeyEvent.VK_S);
        btnRetour.setMnemonic(KeyEvent.VK_R);
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        g.drawImage(IMAGE_SLOTS, 0, 0, null);      

    }
}
